/*
   Copyright 2009 Abdulla Abdurakhmanov (abdulla@latestbit.com)
   Original sources are available at www.latestbit.com

   Licensed under the Apache License, Version 2.0 (the "License");
   you may not use this file except in compliance with the License.
   You may obtain a copy of the License at

       http://www.apache.org/licenses/LICENSE-2.0

   Unless required by applicable law or agreed to in writing, software
   distributed under the License is distributed on an "AS IS" BASIS,
   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   See the License for the specific language governing permissions and
   limitations under the License.
*/

package org.latestbit.smartobjects;

import java.nio.ByteBuffer;

import org.latestbit.smartobjects.coders.IDataTypesCoder;
import org.latestbit.smartobjects.encrypters.IDataEncrypter;
import org.latestbit.smartobjects.exceptions.*;
import org.latestbit.smartobjects.io.ResizableByteBuffer;

/**
 * Base interface for all serializable (to bytes) objects for the specified coder and encrypter
 * @author abdulla-a
 *
 */
public interface ISerializableObject {

	/**
	 * Serializes object fields to bytes
	 * @param coder Coder implementation
	 * @param encrypter Encrypter implementation
	 * @param writeBuffer Output resizable byte buffer
	 * @throws SmartBusSystemException
	 */
	public void serialize(IDataTypesCoder coder, IDataEncrypter encrypter, ResizableByteBuffer writeBuffer)
		throws SmartBusSystemException;
	
	/**
	 * Deserializes bytes to object fields
	 * @param coder Coder implementation
	 * @param encrypter Encrypter implementation
	 * @param readBuffer Input byte buffer
	 * @throws SmartBusSystemException
	 */
	public void deserialize(IDataTypesCoder coder, IDataEncrypter encrypter, ByteBuffer readBuffer)
		throws SmartBusSystemException;
	
	/**
	 * Gets constant SIDL object type of string
	 * @return stringified SIDL object type
	 */
	public String getObjectType();
}
